﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
	<Style x:Key="ContextMenuKey" TargetType="{x:Type ContextMenu}">
		<Setter Property="SnapsToDevicePixels" Value="True" />
		<Setter Property="OverridesDefaultStyle" Value="True" />
		<Setter Property="Grid.IsSharedSizeScope" Value="True" />
		<Setter Property="FontFamily" Value="Segoe UI, /Daytimer.Fonts;component/#WeblySleek UI Normal" />
		<Setter Property="FontSize" Value="12" />
		<Setter Property="FontWeight" Value="Normal" />
		<Setter Property="Foreground" Value="#FF5E5E5E" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ContextMenu}">
					<Border>
						<Border.Effect>
							<DropShadowEffect ShadowDepth="0" Opacity="0.5" Color="#FFBBBBBB" />
						</Border.Effect>
						<Border x:Name="Border" Background="{DynamicResource ContextMenuBackground}" BorderThickness="1"
								BorderBrush="{DynamicResource ContextMenuBorder}" Margin="4">
							<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" Margin="1" />
						</Border>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<Style TargetType="{x:Type ContextMenu}" BasedOn="{StaticResource ContextMenuKey}" />
	<MenuScrollingVisibilityConverter x:Key="MenuScrollingVisibilityConverter" />
	<Geometry x:Key="DownArrow">M 0 0 3.5 4 7 0 Z</Geometry>
	<Geometry x:Key="UpArrow">M 0 4 3.5 0 7 4 Z</Geometry>
	<Geometry x:Key="RightArrow">M 0 0 4 3.5 0 7 Z</Geometry>
	<Style x:Key="MenuScrollButton" TargetType="{x:Type RepeatButton}" BasedOn="{x:Null}">
		<Setter Property="ClickMode" Value="Hover" />
		<Setter Property="MinWidth" Value="0" />
		<Setter Property="MinHeight" Value="0" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type RepeatButton}">
					<DockPanel Background="Transparent" SnapsToDevicePixels="True">
						<Rectangle DockPanel.Dock="Right" x:Name="R1" Width="1" Fill="Transparent" />
						<Rectangle DockPanel.Dock="Bottom" x:Name="B1" Height="1" Fill="Transparent" />
						<Rectangle DockPanel.Dock="Left" x:Name="L1" Width="1" Fill="Transparent" />
						<Rectangle DockPanel.Dock="Top" x:Name="T1" Height="1" Fill="Transparent" />
						<ContentPresenter x:Name="ContentContainer" Margin="0" VerticalAlignment="Center"
								HorizontalAlignment="Center" />
					</DockPanel>
					<ControlTemplate.Triggers>
						<Trigger Property="IsPressed" Value="True">
							<Setter TargetName="R1" Property="Fill"
									Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}" />
							<Setter TargetName="B1" Property="Fill"
									Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}" />
							<Setter TargetName="L1" Property="Fill"
									Value="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" />
							<Setter TargetName="T1" Property="Fill"
									Value="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" />
							<Setter TargetName="ContentContainer" Property="Margin" Value="3,3,1,1" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<!--ScrollViewer for a MenuItem-->
	<Style x:Key="MenuScrollViewer" TargetType="{x:Type ScrollViewer}" BasedOn="{x:Null}">
		<Setter Property="HorizontalScrollBarVisibility" Value="Hidden" />
		<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
		<Setter Property="Template">
			<Setter.Value>
				<!--ScrollViewer for a MenuItem-->
				<ControlTemplate TargetType="{x:Type ScrollViewer}">
					<Grid SnapsToDevicePixels="True">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="*" />
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" />
							<RowDefinition Height="*" />
							<RowDefinition Height="Auto" />
						</Grid.RowDefinitions>
						<Border Grid.Row="1" Grid.Column="0">
							<ScrollContentPresenter Margin="{TemplateBinding Padding}" />
						</Border>
						<RepeatButton Style="{StaticResource MenuScrollButton}" Grid.Row="0" Grid.Column="0"
								Command="{x:Static ScrollBar.LineUpCommand}"
								CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
								Focusable="False">
							<RepeatButton.Visibility>
								<MultiBinding FallbackValue="Visibility.Collapsed"
										Converter="{StaticResource MenuScrollingVisibilityConverter}"
										ConverterParameter="0">
									<Binding RelativeSource="{RelativeSource TemplatedParent}"
											Path="ComputedVerticalScrollBarVisibility" />
									<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalOffset" />
									<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ExtentHeight" />
									<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ViewportHeight" />
								</MultiBinding>
							</RepeatButton.Visibility>
							<Path Fill="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"
									Data="{StaticResource UpArrow}" />
						</RepeatButton>
						<RepeatButton Style="{StaticResource MenuScrollButton}" Grid.Row="2" Grid.Column="0"
								Command="{x:Static ScrollBar.LineDownCommand}"
								CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
								Focusable="False">
							<RepeatButton.Visibility>
								<MultiBinding FallbackValue="Visibility.Collapsed"
										Converter="{StaticResource MenuScrollingVisibilityConverter}"
										ConverterParameter="100">
									<Binding RelativeSource="{RelativeSource TemplatedParent}"
											Path="ComputedVerticalScrollBarVisibility" />
									<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalOffset" />
									<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ExtentHeight" />
									<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ViewportHeight" />
								</MultiBinding>
							</RepeatButton.Visibility>
							<Path Fill="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"
									Data="{StaticResource DownArrow}" />
						</RepeatButton>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
		<Setter Property="Height" Value="1" />
		<Setter Property="Margin" Value="0,1" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Separator}">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="Auto" SharedSizeGroup="Icon" />
							<ColumnDefinition />
						</Grid.ColumnDefinitions>
						<Rectangle Grid.Column="1" Fill="{DynamicResource ContextMenuSeparator}" />
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<!-- SubmenuItem -->
	<ControlTemplate x:Key="{x:Static MenuItem.SubmenuItemTemplateKey}" TargetType="{x:Type MenuItem}">
		<Border x:Name="Border" Background="Transparent">
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto" SharedSizeGroup="Icon" />
					<ColumnDefinition Width="*" />
					<ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut" />
					<ColumnDefinition Width="15" />
				</Grid.ColumnDefinitions>
				<Border x:Name="IconCheck" Visibility="Hidden" Width="20" Height="20" BorderThickness="1"
						BorderBrush="{DynamicResource ContextMenuIconCheckBorder}"
						Background="{DynamicResource ContextMenuIconCheckBackground}" VerticalAlignment="Center" />
				<ContentPresenter x:Name="Icon" Margin="6,0,6,0" Width="16" Height="16" VerticalAlignment="Center"
						ContentSource="Icon" />
				<Border x:Name="Check" Width="13" Height="13" Visibility="Collapsed" HorizontalAlignment="Center"
						VerticalAlignment="Center" BorderThickness="1" Background="Transparent">
					<Path x:Name="CheckMark" Width="9" Height="8" Visibility="Hidden" SnapsToDevicePixels="False"
							StrokeThickness="1.5" Data="M 0 3.5 3 6.5 8 0" Stroke="{DynamicResource GlyphColor}" />
				</Border>
				<ContentPresenter x:Name="HeaderHost" Grid.Column="1" VerticalAlignment="Center" ContentSource="Header"
						RecognizesAccessKey="True" />
				<TextBlock x:Name="InputGestureText" Grid.Column="2" Text="{TemplateBinding InputGestureText}"
						Margin="20,0,0,0" DockPanel.Dock="Right" VerticalAlignment="Center" />
			</Grid>
		</Border>
		<ControlTemplate.Triggers>
			<Trigger Property="Icon" Value="{x:Null}">
				<Setter TargetName="IconCheck" Property="Opacity" Value="0" />
				<Setter TargetName="Icon" Property="Visibility" Value="Hidden" />
			</Trigger>
			<Trigger Property="IsChecked" Value="True">
				<Setter TargetName="IconCheck" Property="Visibility" Value="Visible" />
			</Trigger>
			<MultiTrigger>
				<MultiTrigger.Conditions>
					<Condition Property="IsChecked" Value="True" />
					<Condition Property="Icon" Value="{x:Null}" />
				</MultiTrigger.Conditions>
				<Setter TargetName="CheckMark" Property="Visibility" Value="Visible" />
			</MultiTrigger>
			<MultiTrigger>
				<MultiTrigger.Conditions>
					<Condition Property="IsCheckable" Value="True" />
					<Condition Property="Icon" Value="{x:Null}" />
				</MultiTrigger.Conditions>
				<Setter TargetName="Check" Property="Visibility" Value="Visible" />
			</MultiTrigger>
			<Trigger Property="IsHighlighted" Value="True">
				<Setter Property="Background" TargetName="Border" Value="{DynamicResource ContextMenuHoverBackground}" />
			</Trigger>
			<Trigger Property="IsEnabled" Value="False">
				<Setter Property="Opacity" TargetName="Check" Value="0.5" />
				<Setter Property="Opacity" TargetName="Icon" Value="0.5" />
				<Setter Property="Foreground" Value="{DynamicResource ContextMenuDisabledForeground}" />
			</Trigger>
		</ControlTemplate.Triggers>
	</ControlTemplate>
	<ControlTemplate x:Key="{x:Static MenuItem.SubmenuHeaderTemplateKey}" TargetType="{x:Type MenuItem}">
		<Border x:Name="Border" Background="Transparent">
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto" SharedSizeGroup="Icon" />
					<ColumnDefinition Width="*" />
					<ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut" />
					<ColumnDefinition Width="15" />
				</Grid.ColumnDefinitions>
				<ContentPresenter x:Name="Icon" Margin="6,0,6,0" Width="16" Height="16" VerticalAlignment="Center"
						ContentSource="Icon" />
				<ContentPresenter x:Name="HeaderHost" Grid.Column="1" ContentSource="Header" VerticalAlignment="Center"
						RecognizesAccessKey="True" />
				<TextBlock x:Name="InputGestureText" Grid.Column="2" Text="{TemplateBinding InputGestureText}"
						Margin="20,0,0,0" DockPanel.Dock="Right" VerticalAlignment="Center" />
				<Path Grid.Column="3" HorizontalAlignment="Left" VerticalAlignment="Center" Data="M 0 0 0 7 4 3.5 Z"
						RenderOptions.EdgeMode="Aliased" Fill="{DynamicResource GlyphColor}" Margin="2,0,0,0" />
				<Popup x:Name="Popup" Placement="Right" IsOpen="{TemplateBinding IsSubmenuOpen}"
						AllowsTransparency="True" Focusable="False" PopupAnimation="Fade" HorizontalOffset="-5"
						VerticalOffset="-4">
					<Border>
						<Border.Effect>
							<DropShadowEffect ShadowDepth="0" Opacity="0.5" Color="#FFBBBBBB" />
						</Border.Effect>
						<Border x:Name="SubmenuBorder" SnapsToDevicePixels="True"
								Background="{DynamicResource ContextMenuBackground}" BorderThickness="1"
								BorderBrush="{DynamicResource ContextMenuBorder}" Margin="4">
							<ScrollViewer CanContentScroll="True" Style="{StaticResource MenuScrollViewer}">
								<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"
										Margin="1" />
							</ScrollViewer>
						</Border>
					</Border>
				</Popup>
			</Grid>
		</Border>
		<ControlTemplate.Triggers>
			<Trigger Property="Icon" Value="{x:Null}">
				<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
			</Trigger>
			<Trigger Property="IsHighlighted" Value="True">
				<Setter Property="Background" TargetName="Border" Value="{DynamicResource ContextMenuHoverBackground}" />
			</Trigger>
			<Trigger Property="IsEnabled" Value="False">
				<Setter Property="Opacity" TargetName="Icon" Value="0.5" />
				<Setter Property="Foreground" Value="{DynamicResource ContextMenuDisabledForeground}" />
			</Trigger>
		</ControlTemplate.Triggers>
	</ControlTemplate>
	<!-- MenuItem Style -->
	<Style x:Key="MenuItemKey" TargetType="{x:Type MenuItem}">
		<Setter Property="OverridesDefaultStyle" Value="True" />
		<Setter Property="Height" Value="24" />
		<Style.Triggers>
			<Trigger Property="Role" Value="SubmenuHeader">
				<Setter Property="Template" Value="{StaticResource {x:Static MenuItem.SubmenuHeaderTemplateKey}}" />
			</Trigger>
			<Trigger Property="Role" Value="SubmenuItem">
				<Setter Property="Template" Value="{StaticResource {x:Static MenuItem.SubmenuItemTemplateKey}}" />
			</Trigger>
		</Style.Triggers>
	</Style>
	<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource MenuItemKey}" />
</ResourceDictionary>